package com.tuanbiao.models.action;

import androidx.annotation.NonNull;

import com.hzjq.data.callback.Callback;
import com.hzjq.lib.BlastKool;
import com.hzjq.lib.callback.OnAppStartCheckerUpgradeFirmwareCallback;
import com.hzjq.lib.callback.OnCheckerUpgradeFirmwareCallback;
import com.hzjq.lib.checker.CheckError;
import com.tuanbiao.data.callback.OnBaseResultCallback;

import timber.log.Timber;

/**
 * @author abiao
 * @since 2022/4/24 15:02
 */
public interface CheckAction {
    default void setCheckerUpgradeFirmwareCallback() {
        BlastKool.Companion.loader().setCheckerUpgradeFirmwareCallback(new OnAppStartCheckerUpgradeFirmwareCallback() {
            @Override
            public void onAppStartCheckerUpgradeFirmware(@NonNull OnCheckerUpgradeFirmwareCallback onCheckerUpgradeFirmwareCallback) {

            }
        });
    }
    default void startAppCheck(OnBaseResultCallback<CheckError> callback,OnBaseResultCallback<OnCheckerUpgradeFirmwareCallback> upgradeCallback) {
        BlastKool.Companion.loader().checker().checkStartApp(new Callback<CheckError>() {
            @Override
            public void run(CheckError error) {
                callback.onSuccess(error);
                callback.onFinish();
            }
        }, new OnAppStartCheckerUpgradeFirmwareCallback() {
            @Override
            public void onAppStartCheckerUpgradeFirmware(@NonNull OnCheckerUpgradeFirmwareCallback onCheckerUpgradeFirmwareCallback) {
                upgradeCallback.onSuccess(onCheckerUpgradeFirmwareCallback);
                upgradeCallback.onFinish();
            }
        });
    }

    default void checkNetted(OnBaseResultCallback<CheckError> callback) {
        Timber.i("checkNetted");
        BlastKool.Companion.loader().checker().checkNetted(new Callback<CheckError>() {
            @Override
            public void run(CheckError error) {
                Timber.i("checkNetted:" + error.getErrorCode() + "," + error.getErrorMsg());
                callback.onSuccess(error);
                callback.onFinish();
            }
        });
    }

    default void blastCheck(OnBaseResultCallback<CheckError> callback) {
        BlastKool.Companion.loader().checker().checkBlast(error -> {
            Timber.i("blastCheck:" + error.getErrorCode() + "," + error.getErrorMsg());
            callback.onSuccess(error);
            callback.onFinish();
        });
    }

    default void netCheck(OnBaseResultCallback<CheckError> callback) {
        BlastKool.Companion.loader().checker().checkNetWork(error -> {
            callback.onSuccess(error);
            callback.onFinish();
        });
    }

}
